package com.wqh.article.command;

import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.wqh.article.entity.User;
import com.wqh.article.service.ArticleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * @author wanqh
 * @date 2018/01/14 21:02
 * @description: 批量请求命令
 */
public class UserBatchCommand extends HystrixCommand<List<User>> {
    private final Logger logger =  LoggerFactory.getLogger(UserCommand.class);
    private List<Long> ids;
    private ArticleService articleService;

    public UserBatchCommand(ArticleService articleService,List<Long> ids){
        super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("userGroup")));
        this.ids = ids;
        this.articleService = articleService;
    }
    @Override
    protected List<User> run() throws Exception {
        return articleService.findUserByIds(ids);
    }
}
